import requests

from apis.base_api import BaseApi
from untils.log_ import logger

base_url = 'http://kdtx-test.itheima.net'


class CoursesManagement(BaseApi):

    def add(self, Body):
        """
        新增课程
        :param Body:
        :return:
        """
        url = self.base_url + "/api/clues/course"
        logger.debug(f"token：{self.token}")
        response_json = self.send(send_method="post", send_url=url, json=Body)
        return response_json

    def queryList(self):
        """
        查询课程列表
        :return:
        """
        url = self.base_url + "/api/clues/course/list"
        response_json = self.send(send_method="get", send_url=url)
        return response_json

    def queryDetail(self, id):
        """
        查询课程详情
        :return:
        """
        url = self.base_url + f"/api/clues/course/{id}"
        response_json = self.send(send_method="get", send_url=url)
        return response_json

    def update(self, Body):
        """
        更新课程信息
        :return:
        """
        url = self.base_url + "/api/clues/course"
        response_json = self.send(send_method="put", send_url=url, json=Body)
        return response_json

    def delete(self, id):
        """
        删除课程
        :return:
        """
        url = self.base_url + f"/api/clues/course/{id}"
        response_json = self.send(send_method="delete", send_url=url)
        return response_json

